package chpt06;

public class LambdaTest {

	public static void main(String[] args) {
		// 0. Lambda表达式的基本格式
		IMathOperation mo0 = (int a, int b) -> {return a + b;};
		System.out.println("基本格式：" + mo0.operation(1, 2));
		// 1. 省略大括号
		IGreeting greeting = 
				(String msg) -> System.out.println("Hello " + msg);
		greeting.sayHello("Lambda");
		// 2. 省略圆括号
		greeting = msg -> System.out.println("Hello " + msg);
		greeting.sayHello("Lambda expression");	
		// 3. 省略return
		IMathOperation mo1 = (int a, int b) -> a - b;
		System.out.println("省略格式：" + mo1.operation(3, 4));
        // 4. 省略参数类型和大括号
		IMathOperation mo2 = (a, b) -> a * b;
		System.out.println("省略格式：" + mo2.operation(3, 4));
	}
}
